//
//  ViewController.m
//  UI02_HomeWork_01
//
//  Created by Bodi on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "BodiLabel.h"
#import "BodiTextField.h"
#import "BodiButton.h"

@interface ViewController ()<UITextFieldDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self creatUiLable];
    [self creatTextfield];
    [self creatButton];
}
-(void)creatUiLable{
    BodiLabel *label1 = [[BodiLabel alloc]initWithFrame:CGRectMake(50, 50, 80, 40) withName:@"用户名"];
    [self.view addSubview:label1];
    [label1 release];
    BodiLabel *label2 = [[BodiLabel alloc]initWithFrame:CGRectMake(50, 120, 80, 40) withName:@"密码"];
    [self.view addSubview:label2];
    [label2 release];
    
    BodiLabel *label3 = [[BodiLabel alloc]initWithFrame:CGRectMake(50, 190, 80, 40) withName:@"确认密码"];
    [self.view addSubview:label3];
    [label3 release];
    BodiLabel *label4 = [[BodiLabel alloc]initWithFrame:CGRectMake(50, 260, 80, 40) withName:@"手机号"];
    [self.view addSubview:label4];
    [label4 release];
    BodiLabel *label5 = [[BodiLabel alloc]initWithFrame:CGRectMake(50, 330, 80, 40) withName:@"邮箱"];
    [self.view addSubview:label5];
    [label5 release];
}
-(void)creatTextfield{
    BodiTextField *text1 =[[BodiTextField alloc]initWithFrame:CGRectMake(150, 50, 200, 40) withPlace:@"请输入用户名"];
    [self.view addSubview:text1];
    [text1 release];
    text1.delegate = self;
    BodiTextField *text2 =[[BodiTextField alloc]initWithFrame:CGRectMake(150, 120, 200, 40) withPlace:@"请输入密码"];
    
    [self.view addSubview:text2];
    [text2 release];
    text2.delegate = self;

    BodiTextField *text3 =[[BodiTextField alloc]initWithFrame:CGRectMake(150, 190, 200, 40) withPlace:@"再次输入密码"];
    
    [self.view addSubview:text3];
    [text3 release];
    text3.delegate = self;


    BodiTextField *text4 =[[BodiTextField alloc]initWithFrame:CGRectMake(150, 260, 200, 40) withPlace:@"请输入联系方式"];
    

    
    [self.view addSubview:text4];
    [text4 release];
    text4.delegate = self;
    BodiTextField *text5 =[[BodiTextField alloc]initWithFrame:CGRectMake(150, 330, 200, 40) withPlace:@"请输入邮箱"];
    
    [self.view addSubview:text5];
    [text5 release];
    text5.delegate = self;

}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    // 参数textField 和 userTextField 指向同一内存空间  二者相同
    NSLog(@"textField: %@",textField);
    
    //撤销第一响应者
    /**resignfirstResponder 是 UIResponder的方法*/
    [textField resignFirstResponder];
    
    return YES;
    
}
-(void)creatButton{
    BodiButton *button1 = [BodiButton buttonWithType:UIButtonTypeSystem withFrame:CGRectMake(120, 400, 30, 30) withTitle:@"注册"];
    [self.view addSubview:button1];
    
    BodiButton *button2 = [BodiButton buttonWithType:UIButtonTypeSystem withFrame:CGRectMake(280, 400, 30, 30) withTitle:@"取消"];
    [self.view addSubview:button2];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
